package cn.itcast.n3_Java线程;

import lombok.extern.slf4j.Slf4j;

import static cn.itcast.util.Sleeper.sleep;


/**
 * @program: juc
 * @description:
 * @author: flyduck
 * @create: 2024-08-28 17:04
 **/
@Slf4j(topic = "c.Test14_join方法_在打印之前调用t1_join方法_等待t1运行完成")
public class Test14_join方法_在打印之前调用t1_join方法_等待t1运行完成 {
    static int r = 0;
    public static void main(String[] args) throws InterruptedException {
        test1();
    }
    private static void test1() throws InterruptedException {
        log.debug("开始");
        Thread t1 = new Thread(() -> {
            log.debug("开始");
            sleep(1);
            log.debug("结束");
            r = 10;
        },"t1");
        t1.start();
        t1.join();
        log.debug("结果为:{}", r);//结果为:0
        log.debug("结束");
    }
}
